#pragma once

#include "TrueText/Types.h"
#include "TrueText/BitmapInfo.h"

namespace TrueText {

enum BlendMode
{
	BLEND_ALPHA_COMPOSE,
	BLEND_MAX,
	BLEND_OVERWRITE
};

class BlittingFunction 
{
public:
	BlittingFunction()
		: blendMode(BLEND_OVERWRITE)
	{ }

	BlittingFunction(const BlittingFunction& rhs)
		: color(rhs.color)
		, blendMode(rhs.blendMode)
	{ }

	const BlittingFunction& operator=(const BlittingFunction& rhs)
	{
		if (&rhs == this)
			return *this;

		color = rhs.color;
		blendMode = rhs.blendMode;

		return *this;
	}

	~BlittingFunction()
	{ }

	// Blit single pixel of given intensity to given address using current pixel format.
	// Intensity should fit in range 0..255	
	void BlitPixel(int intensity, void* dst, PixelFormat dstFormat) const;

	const Color& GetColor() const { return color; }
	void SetColor(const Color& value) { color = value; }

	BlendMode GetBlendMode() const { return blendMode; }
	void SetBlendMode(BlendMode value) { blendMode = value; }
protected:
	void DoBlitPixel(int intensity, void* dst, PixelFormat dstFormat) const;
private:
	BlendMode blendMode;
	Color color;
	bool ignoreSource;
};

}